#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/7/27 22:46
# @Author : lixinpan
# @Site : 
# @File : hash_object.py
# @function:
'''
如果一个对象是可散列的，那么在这个对象的生命周期中，它的散列值是不变的，而且这个对象需要实现__hash__（　）方法。
如果两个可散列对象是相等的，那么它们的散列值一定是一样的……
'''

tt = (1, 2, (30, 40))
print(hash(tt))

# t1 与tt相同
t1 = (1, 2, (30, 40))
print(hash(t1))

# t2包含可变元素list,所以是不可hash的
t2 = (1, 2, [30, 40])
# print(hash(t2))

tf = (1, 2, frozenset([30, 40]))
print(hash(tf))

'''
字典的N中初始化方法
'''
a = dict(one=1, two=2, three=3)
b = {'one': 1, 'two': 2, 'three': 3}
c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
d = dict([('two', 2), ('one', 1), ('three', 3)])
e = dict({'three': 3, 'two': 2, 'one': 1})
assert a == b == c == d == e

'''
字典的推导初始化方法
'''
DIAL_CODES=[(86,'china'),(91,'india'),(1,'united states')]
# 格式为｛key:value for key,value in the_list｝
country_code = {country:code for code, country in DIAL_CODES}
print(country_code)


for line_no, line  in enumerate(fp,1):
    pass